import System(getArgs)
import Test

data Queue a = Queue [a] [a] Int Int

makeTup (Queue l r ll lr) = (l, r, ll, lr)

newQueue = Queue [] [] 0 0

rot [] (x:r) a = x:a
rot (x:l) (y:r) a = x:(rot l r (y:a))

push x (Queue l r ll lr) = if lr == ll
                           then (Queue (rot l (x:r) []) [] (ll + lr + 1) 0)
                           else (Queue l (x:r) ll (lr + 1))

remove (Queue (x:l) r ll lr) = if lr == ll
                               then (Queue (rot l r []) [] ((ll - 1) + lr) 0)
                               else (Queue l r (ll - 1) lr)

peek (Queue (x:l) _ _ _) = x

main = do args <- getArgs
          writeFile "result.dat" ("Queue 4 Results:" ++ "\n")
          --Test.multiTest push remove newQueue makeTup (rInt (head args)) (rInt (head (tail args)))
          --Test.pushPop push remove newQueue makeTup (rInt (head args))
          let q = Test.pushntimes push newQueue (rInt (head args))
          writeFile "out.dat" (show (makeTup q))
          --Test.removeTest remove q makeTup (rInt (head args)) (rInt (head (tail args))) 0
          --Test.pushTest push peek newQueue makeTup (rInt (head args)) (rInt (head (tail args))) 0
          --Test.pushremovenTest push remove newQueue makeTup (rInt (head args)) (rInt (head (tail args))) 0
          --Test.repeatTest push remove peek newQueue (push 1 newQueue) makeTup (rInt (head args)) (rInt (head (tail args))) 0
          Test.rrTest push remove peek (Test.pushntimes push newQueue (rInt (head (tail args)))) makeTup (rInt (head args)) (rInt (head (tail args))) 0